package aspect;

import annotation.PrivilegeAnno;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import privilegeUtil.PrivilegeUtil;

import java.util.List;

@Component
@Aspect
public class PrivilegeAspect {

    @Around("execution(* service..*.*(..))"+"&& @annotation(anno)")
    public Object around(ProceedingJoinPoint joinPoint, PrivilegeAnno anno) throws Throwable {

        Object o=null;

        List<String> priList= PrivilegeUtil.getPriList();   //find  delete
        String AnnoName=anno.name();   //  add

        if(priList.contains(AnnoName)){
            //代表有权限

            System.out.println("博士已取得白面枭最高权限");

            return  joinPoint.proceed();
        }else{
            //代表没有权限
            System.out.println("你莫得权限");
            return o;
        }




    }



}
